package com.jia.videos.controller;


import com.jia.videos.common.lang.R;
import com.jia.videos.entity.Types;
import com.jia.videos.service.TypesService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dujiajia
 * @since 2020-12-21
 */
@RestController
@RequestMapping("/videos/types")
@CrossOrigin
@Api(tags = "具体小分类管理")
public class TypesController {

    @Autowired
    TypesService typesService;

    @GetMapping("list")
    public R list() {
        List<Types> list = typesService.list();
        return R.ok().data("data",list);
    }

    @PostMapping("save")
    public R save(@RequestBody Types types){
        typesService.save(types);
        return R.ok();
    }

    @PutMapping("update")
    public R update(@RequestBody Types types){
        typesService.updateById(types);
        return R.ok();
    }

    @DeleteMapping("delete/{id}")
    public R delete(@PathVariable Long id){
        typesService.removeById(id);
        return R.ok();
    }

}

